package com.ts.api.module.match.market.internal.sort.context;

import com.ts.api.module.match.core.MatchRegisterContext;
import com.ts.api.module.match.market.internal.sort.strategy.ChanelMarketCustomSort;
import com.ts.api.module.match.market.internal.sort.strategy.ChanelMarketPriceSort;
import com.ts.api.module.match.market.internal.sort.strategy.ChanelMarketWeightSort;
import com.ts.api.module.match.market.internal.sort.strategy.ChannelMarketSortStrategy;
import org.springframework.stereotype.Component;

/**
 *  计划选择器上下文-匹配结果后
 *
 *  @author Pan
 */
@Component
public class ChannelMarketSortContext extends MatchRegisterContext<ChannelMarketSortType, ChannelMarketSortStrategy> {

    public ChannelMarketSortContext() {
        super(ChannelMarketSortType.class);
        register(ChannelMarketSortType.PRICE,   ChanelMarketPriceSort.class);
        register(ChannelMarketSortType.SORT,  ChanelMarketCustomSort.class);
        register(ChannelMarketSortType.WEIGHT, ChanelMarketWeightSort.class);
    }

    @Override
    public ChannelMarketSortStrategy getContext(ChannelMarketSortType e) {
        return super.getContext(e);
    }

    /**
     *  通过渠道展示贷超类型获取上下文
     *
     *  @author Pan
     *  @param  marketDisplayMode     渠道展示贷超类型
     *  @return ChannelMarketSortStrategy
     */
    public ChannelMarketSortStrategy getContext(Integer marketDisplayMode) {
        ChannelMarketSortType channelMarketSortType = ChannelMarketSortType.getEnum(marketDisplayMode);
        return getContext(channelMarketSortType);
    }
}
